﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;

namespace MoAds.AdAdapters.MillennialMedia
{
    public class MillennialMediaRequest
    {
        public String PlacementId { get; set; }
        public String IPAddress { get; set; }
        public String UserAgent { get; set; }
        public String UniqueId { get; set; }
        public String Mode { get; set; }

        public String GetQueryString()
        {
            StringBuilder sb = new StringBuilder();
            AppendParameter(sb, "apid", PlacementId);
            AppendParameter(sb, "auid", UniqueId);
            AppendParameter(sb, "uip", IPAddress);
            AppendParameter(sb, "ua", UserAgent);
            AppendParameter(sb, "mode", Mode);

            if (sb.Length > 1) sb.Remove(sb.Length - 1, 1);

            return sb.ToString();
        }


        private void AppendParameter(StringBuilder sb, String key, String value)
        {
            if (!String.IsNullOrEmpty(value))
            {
                sb.Append(key);
                sb.Append("=");
                sb.Append(Uri.EscapeDataString(value));
                sb.Append("&");
            }
        }
    }
}
